# -*- coding: utf-8 -*-
#   Copyright (c) 2021 FromVB2Python
#   FromVB2Python is licensed under Mulan PSL v2.
#   You can use this software according to the terms and conditions of the Mulan PSL v2. 
#   You may obtain a copy of Mulan PSL v2 at:
#            http://license.coscl.org.cn/MulanPSL2 
#   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.  
#   See the Mulan PSL v2 for more details.
# 摇奖抽奖

import tkinter as tk
import random


flag = False  # 若flag=True则姓名变化中，否则不变。
# 抽奖姓名
names = ['林黛玉', '薛宝钗', '贾元春', '贾迎春', '贾探春', '贾惜春', '李纨', '妙玉',
     '史湘云', '王熙凤', '贾巧姐', '秦可卿', '晴雯', '麝月', '袭人', '鸳鸯',
     '雪雁', '紫鹃', '碧痕', '平儿', '香菱', '金钏', '司棋', '抱琴', '赖大',
     '焦大', '王善保', '周瑞', '林之孝', '乌进孝', '包勇', '吴贵', '吴新登',
     '邓好时', '王柱儿', '余信', '庆儿', '昭儿', '兴儿', '隆儿', '坠儿', '喜儿',
     '寿儿', '丰儿', '住儿', '小舍儿', '李十儿', '玉柱儿']
def myfun():
    global flag
    btn['text'] = '停止' if not flag else '开始'
    flag = not flag
    if flag:
        myfun1()

def myfun1():
    if flag:
        lbl['text'] = random.choice(names)
        win.after(100, myfun1)
    

win = tk.Tk()
win.title('抽奖程序')

lbl = tk.Label(win, text='****', width=6, font="-family {Times New Roman} -size 72 -weight bold")
btn = tk.Button(win, text='开始', command=myfun, font='-size 36')
lbl.grid(row=0, column=0)
btn.grid(row=0, column=1, padx=10)

win.mainloop()
